var Enemy=function(x,y,source,mode){
    this.x=x;
    this.y=y;
    this.source=source;
    this.mode=mode;
    //this.step=20;
    this.exploded=false;
    this.ended=false;
    this.type=0;
    
    this.loadImage=function (){
        var sWidth=88;
        var sHeight=44;
        var width=50;
        var height=50;
        var imgEnemy = new Image();
        imgEnemy.src = 'Images/'+this.source;
        
        if(this.exploded &&!this.ended){
            context.drawImage(imgEnemy,this.x, this.y,width,height);
            this.ended=true;
        }
        else if(!this.mode && !this.ended){
            context.drawImage(imgEnemy, 0, 0, sWidth/2, sHeight, this.x, this.y, width,height);
        }else if(this.mode && !this.ended){
            context.drawImage(imgEnemy, sWidth/2, 0, sWidth, sHeight, this.x, this.y, width,height);
        }
        else if(this.ended){
            imgEnemy.src = 'Images/ended.png';
        }
    }
    
    this.update=function(x,y,mode){
        this.x=x;
        this.y=y;
        this.mode=mode;
    }
    
    this.updateScore=function(){
        if(this.type==1){
            score+=30;
        }else if(this.type==2){
            score+=20;
        }else if(this.type==3){
            score+=10;
        }
    }
    
}